<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
	<head>
		<title>待审批培训</title>
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/base.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/info-mgt.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/WdatePicker.css" />

		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/jquery.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/common.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/WdatePicker.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/jquery.pagination.js"></script>

	</head>

	<body>
		<div class="title">
			<h2>
				等待审批
			</h2>
		</div>
		<form method="post"
			action="${pageContext.request.contextPath }/TrainMethod.action?method=selectWaitTrain">
			<div class="query">
				<div class="query-conditions ue-clear">
					<div class="conditions name ue-clear">
						<label>
							申请编号：
						</label>
						<p class="long-input ue-clear">
							<input type="text" name="trainid" id="trainid"
								value="${requestScope.select.trainid }">
						</p>
					</div>
					<div class="conditions name ue-clear">
						<label>
							培训人编号：
						</label>
						<p class="long-input ue-clear">
							<input type="text" name="userid" id="userid"
								value="${requestScope.select.userId }">
						</p>
					</div>
					<div class="conditions name ue-clear">
						<label>
							培训人姓名：
						</label>
						<p class="long-input ue-clear">
							<input type="text" name="username" id="username"
								value="${requestScope.select.userName }">
						</p>
					</div>
					<div class="conditions name ue-clear">
						<label>
							人员部门
						</label>
						<p class="long-input ue-clear">
							<select name="userdept" id="userdept">
								<option>
									请选择
								</option>
								<c:forEach items="${requestScope.deptlist }" var="dept"
									varStatus="c">
									<option>
										${dept.deptName }
									</option>
								</c:forEach>
							</select>
						</p>
					</div>
					<div class="conditions name ue-clear">
						<label>
							申请资金
						</label>
						<p class="short-input ue-clear">
							<input type="text" name="trainprice1" id="trainprice1"
								value="${requestScope.select.trainPrice1 }">
							&nbsp;-
							<input type="text" name="trainprice2" id="trainprice2"
								value="${requestScope.select.trainPrice2 }">
						</p>
					</div>
					<div class="conditions name ue-clear">
						<label>
							培训类型
						</label>
						<p class="long-input ue-clear">
							<select name="traintype" id="traintype">
								<option>
									请选择
								</option>
								<option>
									前端制作
								</option>
								<option>
									后台开发
								</option>
								<option>
									项目测试
								</option>
								<option>
									外交公关
								</option>
								<option>
									人事管理
								</option>
							</select>
						</p>
					</div>
				</div>
				<div class="query-btn ue-clear">
					<input type="submit" id="submit" value="查询" />
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="reset" id="reset" value="重置">
				</div>
			</div>
			<div class="table-box">
				<table>
					<thead>
						<tr>
							<th class="num">
								序号
							</th>
							<th class="name">
								申请人id
							</th>
							<th class="process">
								申请人姓名
							</th>
							<th class="time">
								申请人部门
							</th>
							<th class="node">
								开始时间
							</th>
							<th class="time">
								结束时间
							</th>
							<th class="time">
								申请资金
							</th>
							<th class="time">
								培训类型
							</th>
							<th class="operate">
								操作
							</th>
						</tr>
					</thead>
					<c:forEach items="${requestScope.tralist.data }" var="tra"
						varStatus="c">
						<tbody>
							<tr>
								<td class="num">
									${tra.trainingId }
								</td>
								<td class="name">
									${tra.trainingUserId }
								</td>
								<td class="process">
									${tra.trainingUserName }
								</td>
								<td class="node">
									${tra.trainingUserDept }
								</td>
								<td class="time">
									${tra.trainingStartDate }
								</td>
								<td class="time">
									${tra.trainingEndDate }
								</td>
								<td class="time">
									${tra.trainingPrice }
								</td>
								<td class="time">
									${tra.trainingType }
								</td>
								<td class="operate">
									<label style="cursor: pointer; color: blue"
									 onclick="passTrain('${tra.trainingId }','${tra.trainingPrice }','${tra.trainingUserDept }','${requestScope.tralist.currentPage}')">
										通过
									</label>
									<label style="cursor: pointer; color: blue" onclick="refusetrain('${tra.trainingId }','${requestScope.tralist.currentPage}')">
										拒绝
									</label>
								</td>
							</tr>
						</tbody>
					</c:forEach>
				</table>
			</div>
		</form>
		<div>
			<table width="80%" align="center" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<a onclick=skipPage('1');;>首页</a>
					</td>
					<td>
						<a
							onclick="skipPage('${requestScope.tralist.currentPage==1?1:requestScope.tralist.currentPage-1 }');">上一页</a>
					</td>
					<td>
						<a
							onclick="skipPage('${requestScope.tralist.currentPage==requestScope.tralist.totalPage?(requestScope.tralist.currentPage):(requestScope.tralist.currentPage+1) }');">下一页</a>
					</td>
					<td>
						<a onclick="skipPage('${requestScope.tralist.totalPage}');">末页</a>
					</td>
					<td>
						当前页码：${requestScope.tralist.currentPage}/${requestScope.tralist.totalPage}
					</td>
				</tr>
			</table>
		</div>
	</body>
	<script type="text/javascript">
	window.onload=function(){
		$("#traintype option").each(function() {
			if($(this).val()=='${requestScope.select.trainType}'){
				$(this).attr('selected',true);
			}
			});
			$("#userdept option").each(function() {
			if($(this).val()=='${requestScope.select.deptName}'){
				$(this).attr('selected',true);
			}
			});
		}
		function skipPage(currentPage) {
		var url = '${pageContext.request.contextPath }/TrainMethod.action?method=selectWaitTrain&currPage=' + currentPage;
		url += '&userid='+document.getElementById("userid").value;
		url += '&trainid=' + document.getElementById("trainid").value;
		url += '&username=' + document.getElementById("username").value;
		url += '&userdept=' + document.getElementById("userdept").value;
		url += '&trainprice1=' + document.getElementById("trainprice1").value;
		url += '&trainprice2=' + document.getElementById("trainprice2").value;
		url += '&traintype=' + document.getElementById("traintype").value;

		window.location.href = url;
	}
	function passTrain(id,price,dept,currentPage){
		var a = confirm("确认通过?");
		var url = '${pageContext.request.contextPath }/TrainMethod.action?method=passTrain&currPage='+currentPage;
		url += '&userid='+document.getElementById("userid").value;
		url += '&trainid=' + document.getElementById("trainid").value;
		url += '&username=' + document.getElementById("username").value;
		url += '&userdept=' + document.getElementById("userdept").value;
		url += '&trainprice1=' + document.getElementById("trainprice1").value;
		url += '&trainprice2=' + document.getElementById("trainprice2").value;
		url += '&traintype=' + document.getElementById("traintype").value;
		url += '&trainid1=' +id;
		url += '&price=' +price;
		url += '&deptname='+dept;
		if (a) {
			window.location.href = url;
		} else {
			return false;
		}
	}
	
	function refusetrain(id,currentPage){
		var a = confirm("确认拒绝?");
		var url = '${pageContext.request.contextPath }/TrainMethod.action?method=refuseTrain&currPage='+currentPage;
		url += '&userid='+document.getElementById("userid").value;
		url += '&trainid=' + document.getElementById("trainid").value;
		url += '&username=' + document.getElementById("username").value;
		url += '&userdept=' + document.getElementById("userdept").value;
		url += '&trainprice1=' + document.getElementById("trainprice1").value;
		url += '&trainprice2=' + document.getElementById("trainprice2").value;
		url += '&traintype=' + document.getElementById("traintype").value;
		url += '&trainid1=' +id;
		if (a) {
			window.location.href = url;
		} else {
			return false;
		}
	}
	
		
	</script>
</html>
